﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace Pixysoft.Framework.Noebe.MemoryCaches
{
    public interface ICacheDataTable
    {
        /// <summary>
        /// 被缓存的表名
        /// </summary>
        string TableName { get;set;}

        /// <summary>
        /// 设置容量
        /// </summary>
        int Capacity { get;set;}

        /// <summary>
        /// 是否包含缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool Contains(string key);


        /// <summary>
        /// 获取缓存
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        DataTable Get(string key);

        /// <summary>
        /// 获取全部缓存
        /// </summary>
        /// <returns></returns>
        DataTable GetAll();

        /// <summary>
        /// 缓存是否已经过期 只要有一个过期 就全部过期
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        bool IsOverdued(string key);

        /// <summary>
        /// 表结构是否一致
        /// </summary>
        /// <param name="schema"></param>
        /// <returns></returns>
        bool SchemaIsConfirmed(DataTable schema);


        /// <summary>
        /// 添加空数据缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="table"></param>
        void AddNullCache(string key);
        /// <summary>
        /// 添加空数据缓存 timeSpan = milli second
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="table"></param>
        void AddNullCache(string key, int timeSpan);


        void AddShallowCache(string key, DataTable table);
        /// <summary>
        /// 添加浅缓存
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="table"></param>
        void AddShallowCache(string key, int timeSpan, DataTable table);

        void AddShallowCache(string key, params DataRow[] rows);
        /// <summary>
        /// 添加浅缓存  timeSpan = milli second
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="rows"></param>
        void AddShallowCache(string key, int timeSpan, params DataRow[] rows);


        void AddDeepCache(string key, DataTable table);
        /// <summary>
        /// 添加深缓存 timeSpan = milli second
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="table"></param>
        void AddDeepCache(string key, int timeSpan, DataTable table);


        void AddDeepCache(string key, params DataRow[] rows);
        /// <summary>
        /// 添加深缓存 timeSpan = milli second
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeSpan"></param>
        /// <param name="rows"></param>
        void AddDeepCache(string key, int timeSpan, params DataRow[] rows);


        /// <summary>
        /// 清空指定缓存
        /// </summary>
        /// <param name="key"></param>
        void Clear(string key);

        /// <summary>
        /// 清空全部缓存
        /// </summary>
        void ClearAll();

        /// <summary>
        /// 验证缓存数据格式是否符合要求 如果不符合（包括空数据） 返回false
        /// </summary>
        /// <returns></returns>
        bool Verify();

        /// <summary>
        /// 总数据量
        /// </summary>
        int Count { get;}
    }
}
